package kr.hkit.powerjava.chther22.collection;

import java.util.ArrayList;

public class ArrListTest {
	public static void main(String[] args) {
		ArrayList<String> list = new ArrayList<String>();
		list.add("MILK");
		
		ArrayList<String> sublist = new ArrayList<>();
		sublist.add("BREAD");sublist.add("BUTTER");
		
		list.addAll(sublist);
		list.set(1, "APPLE");
		
		
		
		Object[] arr = list.toArray();
		for (int i = 0; i < arr.length; i++) {
			System.out.print(arr[i]+"\t");
		}
		System.out.println();
		String[] strArr = new String[list.size()];
		list.toArray(strArr);
		for (int i = 0; i < strArr.length; i++) {
			System.out.print(strArr[i]+"\t");
		}
		System.out.println();
		list.clear();
		System.out.println(list.isEmpty());
		
		
		/*boolean result = list.contains("BREAD");
		
		System.out.println(result);
		
		System.out.println("==============================================");
		list.remove(1);
		list.remove("BREAD");
		list.clear();*/
		
		for (String str : list) {
			System.out.println(str);
		}
		System.out.println("==============================================");
		for (int i = 0; i < list.size(); i++) {
			System.out.println(list.get(i));
		}
	}
}
